<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div>子元素</div>

  <script>
    window.addEventListener('message', e => {
      // console.log(e.origin) //父页面URL，这里是http://a.index.com
      // console.log(e.source) // 父页面window对象，全等于window.parent/window.top
      console.log(e.data)  //父页面发送的消息
    }, false)
  </script>
</body>

</html>